﻿using System;
using System.Collections.Generic;
using System.Text;
using SysConsole = System.Console;

namespace LSHoude.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            WithStatusMessage();
            SysConsole.WriteLine();
            WithoutStatusMessage();
            SysConsole.WriteLine("\nPress any key to quit.");
            SysConsole.ReadLine();
        }

        private static void WithStatusMessage()
        {
            const int PROGRESS_TOTAL = 999;
            const int SLEEP_TIME_IN_MS = 10;
            SysConsole.WriteLine("Test with status message.");
            using (ProgressBar pBar = new ProgressBar())
            {
                for (int i = 1; i <= PROGRESS_TOTAL; i++)
                {
                    pBar.ProgressInPercentage = (int)((double)i / (double)PROGRESS_TOTAL * 100);
                    pBar.StatusMessage = string.Format("Status message ({0} of {1})", i, PROGRESS_TOTAL);
                    System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 0, SLEEP_TIME_IN_MS));
                }
            }
        }

        private static void WithoutStatusMessage()
        {
            const int PROGRESS_TOTAL = 999;
            const int SLEEP_TIME_IN_MS = 10;
            SysConsole.WriteLine("Test without status message.");
            using (ProgressBar pBar = new ProgressBar())
            {
                for (int i = 1; i <= PROGRESS_TOTAL; i++)
                {
                    pBar.ProgressInPercentage = (int)((double)i / (double)PROGRESS_TOTAL * 100);
                    System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 0, SLEEP_TIME_IN_MS));
                }
            }
            SysConsole.WriteLine("This line should appear immediately below the progress bar.");
        }
    }
}
